/*
* $Id: ViewInspects.cpp 153 2010-09-26 17:33:07Z volok-aleksej@yandex.ru $
*
* Copyright 2009 by Volokitin Alexey
* All rights reserved
*
*/
#include "Common/include.h"
#include "ViewInspects.h"
#include "ViewDefines.h"
#include "ViewFieldValuesHelper.h"
#include "Settings/Journal/RecordViewSettings.h"
#include "Settings/DinIntDefined.h"
#include "Settings/SettingControlIds.h"
#include "Components/Journal/InspectManager.h"

#pragma warning(disable: 4407)

CViewInspect::CViewInspect(CState* pState)
: CViewTable(pState), m_inspectRegion(dynamic_cast<IWnd*>(this)){
	time(&m_tDateTo);
	tm t;
	localtime_s(&t, &m_tDateTo);
	t.tm_yday = 0;
	t.tm_mon = 0;
	t.tm_mday = 1;
	m_tDateFrom = mktime(&t);
}
CViewInspect::~CViewInspect(){}

bool CViewInspect::IsViewState(State state){
	return state.m_nPosTab == Journal::INSPECT_JOURNAL &&
		state.m_type == Journal::NONE &&
		state.m_nTypeSel == Journal::FAMILY;
}
void CViewInspect::SetState(){
	m_pState->m_nState = Journal::VIEW_INSPECT;
	Init();
}
void CViewInspect::Init(){
	m_tableRegion.GetTableDrawer()->ResetTable();
	tableHeader *dateHeader, *frameHeader, *strengthHeader, *existQueenHeader;
	dateHeader = m_tableRegion.GetTableDrawer()->AddHeader(ILanguageManager::GetLanguageManager()->GetString(TABLE_HEADER_DATE_ID), TABLE_INSPECT_DATE_ID, TypeField::DATE);
	frameHeader = m_tableRegion.GetTableDrawer()->AddHeader(ILanguageManager::GetLanguageManager()->GetString(TABLE_HEADER_FRAME_ID), TABLE_INSPECT_FRAME_ID, TypeField::INTEGER);
	strengthHeader = m_tableRegion.GetTableDrawer()->AddHeader(ILanguageManager::GetLanguageManager()->GetString(TABLE_HEADER_BEES_ID), TABLE_INSPECT_STRENGTH_ID, TypeField::INTEGER);
	existQueenHeader = m_tableRegion.GetTableDrawer()->AddHeader(ILanguageManager::GetLanguageManager()->GetString(TABLE_HEADER_EBQ_ID), TABLE_INSPECT_EXIST_QBEE_ID, TypeField::BOOL);
	CRecordViewSettings jSettings;
	tableHeader *waxHeader = NULL, *ambrosiaHeader = NULL, *pumpHeader = NULL;
	if(jSettings.GetCurrentValue(CHECK_GIVE_WOX_ID) == CHECK_BOX_STATE_1)
		waxHeader = m_tableRegion.GetTableDrawer()->AddHeader(ILanguageManager::GetLanguageManager()->GetString(TABLE_HEADER_WAX_ID), TABLE_INSPECT_WAX_ID, TypeField::INTEGER);
	if(jSettings.GetCurrentValue(CHECK_AMBROSIA_ID) == CHECK_BOX_STATE_1)
		ambrosiaHeader = m_tableRegion.GetTableDrawer()->AddHeader(ILanguageManager::GetLanguageManager()->GetString(TABLE_HEADER_AMBROSIA_ID), TABLE_INSPECT_AMBROSIA_ID, TypeField::INTEGER);
	if(jSettings.GetCurrentValue(CHECK_PUMP_HONEY_ID) == CHECK_BOX_STATE_1)
		pumpHeader = m_tableRegion.GetTableDrawer()->AddHeader(ILanguageManager::GetLanguageManager()->GetString(TABLE_HEADER_PUMP_HONEY_ID), TABLE_INSPECT_PUMP_HONEY_ID, TypeField::INTEGER);
	tableHeader *fertHeader = NULL, *diseaseHeader = NULL, *noteHeader = NULL;
	if(jSettings.GetCurrentValue(CHECK_FEEDING_ID) == CHECK_BOX_STATE_1)
		fertHeader = m_tableRegion.GetTableDrawer()->AddHeader(ILanguageManager::GetLanguageManager()->GetString(TABLE_HEADER_FEEDING_ID), TABLE_INSPECT_FEEDING_ID, TypeField::INTEGER);
	if(jSettings.GetCurrentValue(CHECK_DISEASES_ID) == CHECK_BOX_STATE_1)
		diseaseHeader = m_tableRegion.GetTableDrawer()->AddHeader(ILanguageManager::GetLanguageManager()->GetString(TABLE_HEADER_DISEASES_ID), TABLE_INSPECT_DISEASES_ID, TypeField::STRING);
	if(jSettings.GetCurrentValue(CHECK_NOTE_ID) == CHECK_BOX_STATE_1)
		noteHeader = m_tableRegion.GetTableDrawer()->AddHeader(ILanguageManager::GetLanguageManager()->GetString(TABLE_HEADER_NOTE_ID), TABLE_INSPECT_NOTE_ID, TypeField::STRING);
	CViewFieldValuesHelper helper(m_tableRegion.GetTableDrawer());
	helper.GenerateUserHeaders(TypeField::INSPECT, TABLE_INSPECT_USER_ID);
	m_tableRegion.GetTableDrawer()->NormalizeHeader();

	CInspectManager* pInspectManager = IJournalComponent::GetInspectManager();
	std::map<int, CInspectManager::journal> aJournals = pInspectManager->GetFamilyJournal(m_pState->m_nIdParameter);
	for(std::map<int, CInspectManager::journal>::iterator it = aJournals.begin(); it != aJournals.end(); it++){
		if(it->second.m_date < m_tDateFrom || it->second.m_date > m_tDateTo)
			continue;
		CTableCelRow *row = new CTableCelRow(it->first, Journal::VIEW_INSPECT);
		row->AddCel(dateHeader, CConvertFunction::ConvertFromDate(it->second.m_date));
		row->AddCel(frameHeader, CConvertFunction::ConvertFromInt(it->second.m_nFrame));
		row->AddCel(strengthHeader, CConvertFunction::ConvertFromInt(it->second.m_nStrength));
		row->AddCel(existQueenHeader, ILanguageManager::GetLanguageManager()->GetString(QUEEN_BEE_STATUS_DEFAULT_ID + it->second.m_nQBState));
		if(waxHeader)
			row->AddCel(waxHeader, CConvertFunction::ConvertFromInt(it->second.m_nWax));
		if(ambrosiaHeader)
			row->AddCel(ambrosiaHeader, CConvertFunction::ConvertFromInt(it->second.m_nAmbrosia));
		if(pumpHeader)
			row->AddCel(pumpHeader, CConvertFunction::ConvertFromInt(it->second.m_nEvacuation));
		if(fertHeader)
			row->AddCel(fertHeader, CConvertFunction::ConvertFromInt(it->second.m_nDieting));
		if(diseaseHeader)
			row->AddCel(diseaseHeader, ILanguageManager::GetLanguageManager()->GetString(DISEASE_HEALTHY_ID + it->second.m_nDisease));
		if(noteHeader)
			row->AddCel(noteHeader, it->second.m_strNote);
		helper.GenerateUserCels(row, it->second.m_nIdRecord);
		m_tableRegion.GetTableDrawer()->AddCelRow(row);
	}
	m_tableRegion.GetTableDrawer()->SortColumn(TABLE_INSPECT_DATE_ID);
	InitInspect();
}

void CViewInspect::PaintView(CDC* dc, CRect rect){
	__super::PaintView(dc, CRect(rect.left, rect.top + CY_FILTER, rect.right, rect.bottom));
	rect.bottom -= CY_BUTTON_REGION;
	CPen pen;
	pen.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
	dc->MoveTo(rect.TopLeft());
	dc->LineTo(CPoint(rect.right - 1, rect.top));
	dc->LineTo(CPoint(rect.right - 1, rect.bottom));
	pen.DeleteObject();
	CBrush brush;
	brush.CreateSolidBrush(GetSysColor(COLOR_3DFACE));
	dc->FillRect(CRect(rect.left, rect.top + 1, rect.right - 1, rect.top + FILTER_OFFSET), &brush);
	dc->FillRect(CRect(rect.left, rect.bottom - FILTER_OFFSET, rect.right - 1, rect.bottom), &brush);
	dc->FillRect(CRect(rect.left, rect.top + FILTER_OFFSET, rect.left + DATEFROM_OFFSET, rect.bottom - FILTER_OFFSET), &brush);
	dc->FillRect(CRect(rect.left + DATEFROM_OFFSET + SIZE_DATE, rect.top + FILTER_OFFSET,
					rect.left + DATETO_OFFSET, rect.bottom - FILTER_OFFSET), &brush);
	dc->FillRect(CRect(rect.left + SIZE_DATE + DATETO_OFFSET,
					rect.top + FILTER_OFFSET, rect.left + SHOW_BUTTON_OFFSET, rect.bottom - FILTER_OFFSET), &brush);
	dc->FillRect(CRect(rect.left + CX_SHOW_BUTTON + SHOW_BUTTON_OFFSET,
					rect.top + FILTER_OFFSET, rect.right - 1, rect.bottom - FILTER_OFFSET), &brush);
	brush.DeleteObject();
	dc->SetBkMode(TRANSPARENT);
	dc->DrawText(ILanguageManager::GetLanguageManager()->GetString(SHOW_FROM_ID).c_str(),
		CRect(rect.left, rect.top, rect.left + DATEFROM_OFFSET - 5, rect.bottom), DT_RIGHT|DT_VCENTER|DT_SINGLELINE);
	dc->DrawText(ILanguageManager::GetLanguageManager()->GetString(SHOW_TO_ID).c_str(),
		CRect(rect.left + DATEFROM_OFFSET + SIZE_DATE, rect.top, rect.left + DATETO_OFFSET, rect.bottom), DT_CENTER|DT_VCENTER|DT_SINGLELINE);
}

void CViewInspect::ResizeTableRegion(CRect rect){
	rect.bottom -= CY_BUTTON_REGION + CY_FILTER;
	CRect tableRect(rect.left, rect.top, rect.right, rect.bottom - rect.Size().cy/5);
	CRect inspectRect(rect.left, rect.bottom - rect.Size().cy/5 + 1, rect.right, rect.bottom);
	m_tableRegion.SetRect(tableRect);
	m_inspectRegion.SetRect(inspectRect);
}

/************************************************************************/
/*                           Message Function                           */
/************************************************************************/
BEGIN_MESSAGE_MAP(CViewInspect, CViewTable)
	ON_WM_PAINT()
	ON_WM_CREATE()
	ON_WM_SIZE()
	ON_WM_TIMER()
	ON_WM_LBUTTONDOWN()
	ON_WM_KEYDOWN()
	ON_WM_SETCURSOR()
	ON_WM_MOUSEWHEEL()
	ON_WM_HSCROLL()
	ON_WM_VSCROLL()
	ON_COMMAND(BUTTON_SHOW_ID, OnShowButton)
	ON_COMMAND(BUTTON_ADD_ID, OnAddInspect)
	ON_COMMAND(BUTTON_CHANGE_ID, OnChangeInspect)
	ON_COMMAND(BUTTON_DELETE_ID, OnDeleteInspect)
END_MESSAGE_MAP()

void CViewInspect::OnPaint(){
	CPaintDC dc(this);
	CRect rect;
	GetClientRect(rect);
	PaintView(&dc, CRect(rect.left, rect.bottom - CY_BUTTON_REGION - CY_FILTER, rect.right, rect.bottom));
	CPen pen;
	pen.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
	rect.bottom -= (CY_BUTTON_REGION + CY_FILTER);
	dc.MoveTo(CPoint(rect.left, rect.bottom - rect.Size().cy/5));
	dc.LineTo(CPoint(rect.right, rect.bottom - rect.Size().cy/5));
	pen.DeleteObject();
	m_tableRegion.Paint(&dc);
	m_inspectRegion.Paint(&dc);
}
int CViewInspect::OnCreate(LPCREATESTRUCT lpCreateStruct){
	m_dateFrom.Create(WS_CHILD | WS_VISIBLE | DTS_SHORTDATEFORMAT, CRect(), this, DATE_FROM_ID);
	m_dateTo.Create(WS_CHILD | WS_VISIBLE | DTS_SHORTDATEFORMAT, CRect(), this, DATE_TO_ID);
	m_showButton.Create(_T(">>"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, CRect(), this, BUTTON_SHOW_ID);
	SYSTEMTIME t = {0};
	if(m_tDateFrom){
		tm _tm;
		localtime_s(&_tm, &m_tDateFrom);
		t.wDay = _tm.tm_mday;
		t.wMonth = _tm.tm_mon + 1;
		t.wDayOfWeek = _tm.tm_wday;
		t.wYear = _tm.tm_year + 1900;
		m_dateFrom.SetTime(&t);
	}
	if(m_tDateTo){
		tm _tm;
		localtime_s(&_tm, &m_tDateTo);
		t.wDay = _tm.tm_mday;
		t.wMonth = _tm.tm_mon + 1;
		t.wDayOfWeek = _tm.tm_wday;
		t.wYear = _tm.tm_year + 1900;
		m_dateTo.SetTime(&t);
	}
	int ret = __super::OnCreate(lpCreateStruct);
	m_inspectRegion.Create(this);
	return ret;
}
void CViewInspect::OnSize(UINT nType, int cx, int cy){
	CRect rect;
	GetClientRect(rect);
	m_dateFrom.MoveWindow(CRect(rect.left + DATEFROM_OFFSET, rect.bottom - FILTER_REGION + FILTER_OFFSET,
							rect.left + DATEFROM_OFFSET + SIZE_DATE, rect.bottom - CY_BUTTON_REGION - FILTER_OFFSET), TRUE);
	m_dateTo.MoveWindow(CRect(rect.left + DATETO_OFFSET, rect.bottom - FILTER_REGION + FILTER_OFFSET,
							rect.left + SIZE_DATE + DATETO_OFFSET, rect.bottom - CY_BUTTON_REGION - FILTER_OFFSET), TRUE);
	m_showButton.MoveWindow(CRect(rect.left + SHOW_BUTTON_OFFSET, rect.bottom - FILTER_REGION + FILTER_OFFSET,
								rect.left + SHOW_BUTTON_OFFSET + CX_SHOW_BUTTON, rect.bottom - CY_BUTTON_REGION - FILTER_OFFSET), TRUE);
	__super::OnSize(nType, cx, cy);
}
void CViewInspect::OnTimer(UINT_PTR id){
	__super::OnTimer(id);
	if(m_inspectRegion.IsResize()){
		m_inspectRegion.Resize();
		Invalidate(FALSE);
	}
}
void CViewInspect::OnLButtonDown(UINT nFlags, CPoint point){
	CRect rect;
	GetClientRect(rect);
	rect.bottom -= CY_BUTTON_REGION + CY_FILTER;
	CTableRegion* pTable;
	bool bTable = false;
	if(point.y < rect.bottom - rect.Size().cy/5){
		pTable = &m_tableRegion;
		bTable = true;
	}else
		pTable = &m_inspectRegion;
	if(pTable->MouseLBtnDown(point)){
		if(bTable)
			InitInspect();
		UpdateButtons();
		Invalidate(FALSE);
	}
	SetFocus();
	CEmptyViewJournal::OnLButtonDown(nFlags, point);
}
void CViewInspect::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags){
	__super::OnKeyDown(nChar, nRepCnt, nFlags);
	if(nChar == VK_DOWN || nChar == VK_UP)
		InitInspect();
}
BOOL CViewInspect::OnSetCursor(CWnd*, UINT, UINT){
	CPoint posCur;
	GetCursorPos(&posCur);
	CRect rect;
	GetWindowRect(rect);
	posCur = posCur - rect.TopLeft();
	rect.bottom -= CY_BUTTON_REGION + CY_FILTER;
	CTableRegion* pTable;
	if(posCur.y < rect.Size().cy - rect.Size().cy/5)
		pTable = &m_tableRegion;
	else
		pTable = &m_inspectRegion;
	pTable->SetCursor(posCur);
	return TRUE;
}
void CViewInspect::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar){
	if(m_inspectRegion.IsScroll(pScrollBar)){
		m_inspectRegion.Scroll(nSBCode, pScrollBar);
		Invalidate(FALSE);
	}
	__super::OnHScroll(nSBCode, nPos, pScrollBar);
}
void CViewInspect::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar){
	if(m_inspectRegion.IsScroll(pScrollBar)){
		m_inspectRegion.Scroll(nSBCode, pScrollBar);
		Invalidate(FALSE);
	}
	__super::OnVScroll(nSBCode, nPos, pScrollBar);
}

BOOL CViewInspect::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt){
	CRect rect, rectInspect;
	GetWindowRect(rect);
	rect.bottom -= CY_BUTTON_REGION + CY_FILTER;
	rectInspect = rect;
	rect.bottom -= rect.Size().cy/5 + 1;
	rectInspect.top = rect.bottom;
	if(m_tableRegion.IsScroll(SB_VERT))
		rect.right -= SIZE_SCROLL;
	if(m_tableRegion.IsScroll(SB_HORZ))
		rect.bottom -= SIZE_SCROLL;
	if(m_inspectRegion.IsScroll(SB_VERT))
		rectInspect.right -= SIZE_SCROLL;
	if(m_inspectRegion.IsScroll(SB_HORZ))
		rectInspect.bottom -= SIZE_SCROLL;
	if(rect.PtInRect(pt)){
		CPoint pos = pt - rect.TopLeft();
		if(m_tableRegion.IsScroll(SB_VERT))
			OnVScroll(zDelta > 0 ? SB_USER_UP : SB_USER_DOWN, 0, m_tableRegion.GetScroll(SB_VERT));
		Invalidate(FALSE);
		return TRUE;
	}else if(rectInspect.PtInRect(pt)){
		CPoint pos = pt - rect.TopLeft();
		if(m_inspectRegion.IsScroll(SB_VERT))
			OnVScroll(zDelta > 0 ? SB_USER_UP : SB_USER_DOWN, 0, m_inspectRegion.GetScroll(SB_VERT));
		Invalidate(FALSE);
		return TRUE;
	}
	return __super::OnMouseWheel(nFlags, zDelta, pt);
}

void CViewInspect::OnShowButton(){
	m_tDateTo = GetTimeTo();
	m_tDateFrom = GetTimeFrom();
	Init();
	Invalidate(FALSE);
}
void CViewInspect::OnAddInspect(){
	SetManipulation(Journal::ADD_INSPECT, m_pState->m_nIdParameter);
}
void CViewInspect::OnDeleteInspect(){
	CTableCelRow* pSelectRow = m_tableRegion.GetTableDrawer()->GetSelectRow();
	std::tstring strContent = ILanguageManager::GetLanguageManager()->GetString(QUESTION_DELETE_ID);
	if(MessageBox(strContent.c_str(), ILanguageManager::GetLanguageManager()->
		GetString(DELETE_INSPECT_ID).c_str(), MB_YESNO) == IDYES){
		SetManipulation(Journal::DELETE_INSPECT, pSelectRow->GetId());
		m_tableRegion.GetTableDrawer()->DeleteRow(pSelectRow);
		Invalidate(FALSE);
	}
}
void CViewInspect::OnChangeInspect(){
	SetManipulation(Journal::CHANGE_INSPECT, m_tableRegion.GetTableDrawer()->GetSelectRow()->GetId());
}


/************************************************************************/
/*                           User Function                              */
/************************************************************************/
void CViewInspect::InitInspect(){
	m_inspectRegion.GetTableDrawer()->ResetTable();
	tableHeader *nameHousingHeader, *broodHeader, *honeyHeader;
	nameHousingHeader = m_inspectRegion.GetTableDrawer()->AddHeader(ILanguageManager::GetLanguageManager()->GetString(TABLE_HEADER_NAME_HOUSE_ID), TABLE_INSPECT_NAME_HOUSING_ID, TypeField::STRING);
	broodHeader = m_inspectRegion.GetTableDrawer()->AddHeader(ILanguageManager::GetLanguageManager()->GetString(TABLE_HEADER_BROOD_ID), TABLE_INSPECT_BROOD_ID, TypeField::INTEGER);
	honeyHeader = m_inspectRegion.GetTableDrawer()->AddHeader(ILanguageManager::GetLanguageManager()->GetString(TABLE_HEADER_HONEY_ID), TABLE_INSPECT_HONEY_ID, TypeField::INTEGER);
	tableHeader *openBroodHeader = NULL, *closeBroodHeader = NULL, *goodHoneyHeader = NULL;
	CRecordViewSettings settings;
	if(settings.GetCurrentValue(CHECK_OPEN_BROOD_ID) == CHECK_BOX_STATE_1)
		openBroodHeader = m_inspectRegion.GetTableDrawer()->AddHeader(ILanguageManager::GetLanguageManager()->GetString(TABLE_HEADER_OPEN_BROOD_ID), TABLE_INSPECT_OPEN_BROOD_ID, TypeField::INTEGER);
	if(settings.GetCurrentValue(CHECK_SEAL_BROOD_ID) == CHECK_BOX_STATE_1)
		closeBroodHeader = m_inspectRegion.GetTableDrawer()->AddHeader(ILanguageManager::GetLanguageManager()->GetString(TABLE_HEADER_CLOSE_BROOD_ID), TABLE_INSPECT_CLOSE_BROOD_ID, TypeField::INTEGER);
	if(settings.GetCurrentValue(CHECK_GOODS_HONEY_ID) == CHECK_BOX_STATE_1)
		goodHoneyHeader = m_inspectRegion.GetTableDrawer()->AddHeader(ILanguageManager::GetLanguageManager()->GetString(TABLE_HEADER_GOODS_HONEY_ID), TABLE_INSPECT_GOODS_HONEY_ID, TypeField::INTEGER);
	m_inspectRegion.GetTableDrawer()->NormalizeHeader();

	int nIdSelect = 0;
	if(m_tableRegion.GetTableDrawer()->GetSelectRow())
		nIdSelect = m_tableRegion.GetTableDrawer()->GetSelectRow()->GetId();
	CInspectManager* pInspectManager = IJournalComponent::GetInspectManager();
	std::vector<CInspectManager::inspect> aInspects = pInspectManager->GetInspects(nIdSelect);
	for(std::vector<CInspectManager::inspect>::iterator it = aInspects.begin(); it != aInspects.end(); it++){
		CTableCelRow *row = new CTableCelRow(int(it - aInspects.begin()) + 1, Journal::VIEW_INSPECT);
		row->AddCel(nameHousingHeader, it->m_strNameHousing);
		row->AddCel(broodHeader, CConvertFunction::ConvertFromInt(it->m_nBrood));
		row->AddCel(honeyHeader, CConvertFunction::ConvertFromInt(it->m_nHoney));
		if(openBroodHeader)
			row->AddCel(openBroodHeader, CConvertFunction::ConvertFromInt(it->m_nOpenBrood));
		if(closeBroodHeader)
			row->AddCel(closeBroodHeader, CConvertFunction::ConvertFromInt(it->m_nCloseBrood));
		if(goodHoneyHeader)
			row->AddCel(goodHoneyHeader, CConvertFunction::ConvertFromInt(it->m_nGoodHoney));
		m_inspectRegion.GetTableDrawer()->AddCelRow(row);
	}
	m_inspectRegion.GetTableDrawer()->SortColumn(TABLE_INSPECT_NAME_HOUSING_ID);
}

time_t CViewInspect::GetTimeFrom(){
	SYSTEMTIME st;
	m_dateFrom.GetTime(&st);
	tm Tm = {0};
	Tm.tm_year = st.wYear - 1900;
	Tm.tm_mon = st.wMonth - 1;
	Tm.tm_mday = st.wDay;
	return mktime(&Tm);
}

time_t CViewInspect::GetTimeTo(){
	SYSTEMTIME st;
	m_dateTo.GetTime(&st);
	tm Tm = {0};
	Tm.tm_year = st.wYear - 1900;
	Tm.tm_mon = st.wMonth - 1;
	Tm.tm_mday = st.wDay + 1;
	return mktime(&Tm);
}

void CViewInspect::SetManipulation(Journal::typeItemMnpl type, int nId){
	IWnd* pWnd = IVisualManager::GetVisualManager()->
		GetVisualComponent(ILanguageManager::GetLanguageManager()->GetString(JOURNAL_CAPTION_ID))->GetComponentFrame();
	pWnd->Post(UM_ITEM_MANIPULATION, type, nId);
}

void CViewInspect::EventHandler(){
	Init();
	if(IsCreate())
		Invalidate();
}
